# 基础镜像
FROM centos:centos7

ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US.UTF-8
ENV LC_ALL=en_US.UTF-8


RUN cat /etc/yum.repos.d/CentOS-Base.repo

RUN curl -I http://mirrors.aliyun.com/centos/7/os/x86_64/repodata/repomd.xml

RUN sed -i 's|^#baseurl=|baseurl=|' /etc/yum.repos.d/CentOS-Base.repo && \
    sed -i 's|^mirrorlist=|#mirrorlist=|' /etc/yum.repos.d/CentOS-Base.repo && \
    sed -i 's|^baseurl=http://mirror.centos.org/centos/$releasever|baseurl=http://mirrors.aliyun.com/centos/$releasever|' /etc/yum.repos.d/CentOS-Base.repo



# 更新 yum 镜像列表
RUN yum clean all && yum makecache

# 安装 wget
RUN yum -y install wget


RUN yum update -y && \
    yum install -y tar gzip dos2unix && \
    yum clean all

# 安装 Docker（使用阿里云镜像源）
RUN yum install -y yum-utils && \
    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo && \
    yum install -y docker-ce docker-ce-cli containerd.io

# 安装 Docker Compose
RUN curl -L "https://github.com/docker/compose/releases/download/v2.20.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
    chmod +x /usr/local/bin/docker-compose

# 创建 /tmp/harbor 目录
RUN mkdir -p /tmp/harbor
	
COPY harbor-offline-installer-v2.3.0.tgz /tmp/harbor-offline-installer-v2.3.0.tgz

RUN tar -xvf /tmp/harbor-offline-installer-v2.3.0.tgz -C /tmp

COPY harbor.yml /tmp/harbor/harbor.yml
COPY run_harbor.sh /tmp/harbor/run_harbor.sh
COPY prepare /tmp/harbor/prepare

# 使用 dos2unix 转换脚本文件的换行符格式
RUN dos2unix /tmp/harbor/run_harbor.sh

# 设置脚本的可执行权限
RUN chmod +x /tmp/harbor/run_harbor.sh

CMD ["sh", "-c", "ls -l /tmp/harbor/ && cd /tmp/harbor/ &&  ls -la /var/run/ && ls -l /var/run/docker.sock && ls -l /usr/local/bin/ && docker -v && docker load -i  harbor.v2.3.0.tar.gz"]